<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <link rel="stylesheet" href="../../css/my.css">
</head>

<body>
    <!-- 导航栏 -->
    <nav class="ui segment top attached my-shadow-small">
        <div class="ui container">
            <div class="ui menu stackable">
                <div class="item my-font-max my-font-blod my-font-dark">
                    Admin
                </div>
                <a href="" class="item my-font-light my-font-blod my-font-large active"><i class="icon book"></i>博客</a>
                <a href="" class="item my-font-light my-font-blod my-font-large"><i class="icon flag"></i>分类及标签</a>
                               
                <div class="right menu">
                    <div class="ui dropdown item">
                        <div class="text">
                            <img class="ui avatar image" src="https://picsum.photos/100/100.jpg">
                                iron-5
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a class="item" th:href="@{/admin/logout}">注销 </a>
                        </div>
                    </div>
    
                </div>
            </div>
        </div>
    </nav>
    <!-- 二级菜单 -->
    <div class="ui menu attached pointing">
        <div class="ui container">
            <a class="item active" >发布</a>
            <a  class="item">管理</a>
        </div>

    </div>

    <div class="my-container-max" id="container">
        <!-- 表单 -->
        <div class="ui container">
            <!-- 提示 -->
            <!-- <div class="ui success message" th:unless="${#strings.isEmpty(msg)}">
                <i class="close icon" id="close"></i>
                <div class="header">提示：</div>
                <p th:text="${msg}"></p>
            </div> -->
            <form  class="ui form" method="POST" id="blog-form" action="/admin/blog/save">
                <input type="hidden" name="blogId" :value="blog.blogId">
                <div class="field">
                    <div class="ui left labeled input">
                        <div class="ui selection dropdown label">
                            <input type="hidden" name="flag" >
                            <i class="icon dropdown"></i>
                            <div class="default text">原创</div>
                            <div class="menu" >
                                <div class="item" data-value="1">原创</div>
                                <div class="item" data-value="2">转载</div>
                                <div class="item" data-value="3">翻译</div>
                            </div>
                        </div>

                        <input type="text" name="title" placeholder="标题" :placeholder="blog.title">
                    </div>
                   
                    
                </div>
                <div class="field">
                    <textarea name="description" cols="30" rows="5" :placeholder="blog.description"></textarea>
                </div>
                <div class="required field">
                    <div id="md-content" style="z-index: 1 !important;">
                        <textarea cols="30" rows="10" placeholder="内容"name="blogContent" :placeholder="blog.blogContent"></textarea>

                    </div>

                </div>
                <div class="two fields c-padding-big">
                    <div class="required field">
                        <div class="ui left labeled action input">
                            <label class="ui label basic compact">分类</label>
                            <div class="ui selection dropdown fluid">
                                <input type="hidden" name="type.typeId" :value="blog.type.typeId" >
                                <i class="icon dropdown"></i>
                                <div class="default text">分类</div>
                                <div class="menu">
                                    <div class="item" v-for="type in types" :data-value="type.typeId">{{type.typeName}}</div>
                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="field">
                        <div class="ui left labeled action input">
                            <label class="ui label basic compact">标签</label>
                            <select name="tagsId" class="ui dropdown search" multiple>
                                <option value="">标签</option>
                                <option v-for="tag in tags" :value="tag.tagId" >{{tag.tagName}}</option>

                            </select>

                        </div>
                    </div>

                </div>
                <div class="field">
                    <div class="ui left labeled input">
                        <label class="ui basic label">首图</label>
                        <input type="text" :placeholder="blog.firstImg" name="firstImg" >
                    </div>
                </div>
                <div class="inline fields">
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="radio" name="isRecommended" id="isRecommended" :checked="blog.isRecommended" value="true">
                            <label for="isRecommended">推荐</label>

                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="radio" name="isAppreciate" id="isAppreciate" :checked="blog.isAppreciate">
                            <label for="isAppreciate">赞赏</label>

                        </div>
                    </div>

                </div>
                <div class="ui error message"></div>
                <div class="ui right aligned container">
                    <button class="ui button" type="button" onclick="window.history.go(-1)">返回</button>
                    <button class="ui button teal" type="button" id="save-btn">保存</button>
                    <button class="ui button green" type="submit" id="published-btn">发布</button>
                </div>
            </form>
        </div>
    </div>

    <br>




    <script src="../../js/jquery-3.5.1.min.js"></script>
    <script src="../../semanticUI/semantic.min.js"></script>
    <script>
        const container = new Vue({
            el:"#container",
            data:{
                blog:'',
                tags:'',
                types:''
            },
            methods:{
                getBlog(){
                    let _this = this;
                    axios.get("/admin/blog/getBlog").then(
                        function(response){
                            _this.blog = response.data;
                        }
                    )
                },
                getTypes(){
                    let _this = this;
                    axios.get("/admin/type/getTypes").then(
                        function(response){
                            _this.types = response.data;
                        }
                    )
                },
                getTags(){
                    let _this = this;
                    axios.get("/admin/tag/getTags").then(
                        function(response){
                            _this.tags = response.data;
                        }
                    )
                }
            },
            mounted(){
                this.getBlog();
                this.getTags();
                this.getTypes();
            }
        })
    </script>
    <script>
        $(".ui.dropdown").dropdown();
        $('#clear')
            .on('click', function () {
                $('.ui.dropdown').dropdown('clear');
            })

    </script>
</body>

</html>